package com.weigee.ktv.v.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.l.d.app.library.util.ResourceUtil;
import com.weigee.ktv.R;
import com.weigee.ktv.p.TaskDetailContract;
import com.weigee.ktv.p.frag.AboutUsPresenterImpl;
import com.weigee.ktv.v.view.WrapTitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import skin.support.widget.SkinCompatTextView;

/**
 * Created by 林德 on 2017/4/14 14:40.
 * <p/>
 * 关于我们
 */
public class AboutUsFragment extends BaseFragment2 implements TaskDetailContract.AboutUsView
{
    @BindView(R.id.wrap_title_bar)
    WrapTitleBar wrapTitleBar;
    @BindView(R.id.tv_app_version_name)
    SkinCompatTextView tvAppVersionName;
    Unbinder unbinder;

    private TaskDetailContract.AboutUsPresenter presenter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.aboutus_frag, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
    {
        super.onViewCreated(view, savedInstanceState);
        final Context context = view.getContext();

        wrapTitleBar.setTitle(ResourceUtil.string(context, R.string.title_about_us));
        wrapTitleBar.setLeftButton(View.VISIBLE, new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                back();
            }
        });
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);
        getPresenter().onActivityCreated(savedInstanceState);
    }

    @Override
    public void onDestroyView()
    {
        super.onDestroyView();
        unbinder.unbind();
    }

    @NonNull
    @Override
    public Context getMyContext()
    {
        return getActivity();
    }

    @Override
    public TaskDetailContract.AboutUsPresenter getPresenter()
    {
        if (presenter == null)
        {
            presenter = new AboutUsPresenterImpl(this);
        }
        return presenter;
    }

    @Override
    public void setPackageInfo(String versionInfo)
    {
        tvAppVersionName.setText(versionInfo);
    }
}
